function [x1, y1, z1] = Extrapolate3dPoints(x1,y1,z1, maxframes)

i = 1;
bstart = 0;
len = length(x1);


while i <= len
     
     if x1(i) == 0 & bstart == 1
        
         startindex = i-1;
         count = 0;        
      
         while i<=len & x1(i) == 0
             i = i+1;
             count = count+1;             
         end
        
         if count <= maxframes & i<=len
             endindex = i;
                      
             x1a = x1(startindex);
             x1b = x1(endindex);             
             
             y1a = y1(startindex);
             y1b = y1(endindex);             
             
             z1a = z1(startindex);
             z1b = z1(endindex);             
             
             x1step = (x1b-x1a)/(count+1);                                       
             y1step = (y1b-y1a)/(count+1);                          
             z1step = (z1b-z1a)/(count+1);     
                          
             index = startindex+1;
             
             for k = 1:count
                
                 x1(index) = round(x1a+k*x1step);                 
                 y1(index) = round(y1a+k*y1step);                     
                 z1(index) = round(z1a+k*z1step);                                                     
                 
                 index = index+1;                                  
             end
            
         else
             bstart = 0;
         end
     elseif x1(i) > 0
       bstart = 1;       
     end     
     
     i = i+1;
end